/*
 *英才会硕信息科技有限公司拥有本软件的版权，拥有本软件版权2025   并保留所有权利。
 *Copyright 2021,YCHS Information&Science Technology Co.,Ltd,
 *All rights reserved.
 */
package com.ychs.lawyerback01.common;

import lombok.Data;

/**
 * @author xuehongjin
 * @version 1.0
 * @date 2025/8/7
 */
@Data
public class R<T> {
    public R(ResultCode resultCode,T data) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
        this.data =data;
    }
  public R(){

  }
    private Integer code;
    private String msg;
    private T data;
    public static <T>R<T> success(){
        return new R(ResultCode.SUCCESS,null);
    }
    public static <T> R<T> success(T data){
        return new R(ResultCode.SUCCESS,data);
    }
    public static <T> R<T> fail(){
        return new R(ResultCode.ERROR,null);
    }
    //自定义失败返回
    public static <T> R<T> fail(ResultCode resultCode){
        return new R(resultCode,null);
    }
    public static <T> R<T> fail(Integer code,String msg){
        R r =new R();
        r.setCode(code);
        r.setMsg(msg);
        return r;
    }
    public static <T> R<T> fail(ResultCode resultCode,T data){
        return new R(resultCode,data);
    }
}
